<template>
  <div>
    <el-dialog title="学习班信息" v-bind="$attrs" v-on="$listeners" top="80px">
      <el-divider content-position="left">学员登记信息</el-divider>

      <el-row>
        <el-col :span="24">
          <div class="student-info">
            <div>
              <div>姓名</div>
              <div>性别</div>
              <div>单位名称</div>
              <div>人员类型</div>
              <div>学历</div>
            </div>
            <div>
              <div>{{ dataForm.realname }}</div>
              <div>{{ getDict("sex", dataForm.gender) }}</div>
              <div>{{ dataForm.company }}</div>
              <div>{{ getDict("personType", dataForm.persontype) }}</div>
              <div>{{ getDict("Education", dataForm.education) }}</div>
            </div>
            <div>
              <div>身份证</div>
              <div>手机号码</div>
              <div>单位类型</div>
              <div>科室/部门</div>
              <div>职称</div>
            </div>
            <div>
              <div>{{ dataForm.certificatesnumber }}</div>
              <div>{{ dataForm.mobilephone }}</div>
              <div>{{ getDict("dwType", dataForm.companytype) }}</div>
              <div>{{ dataForm.department }}</div>
              <div>{{ dataForm.title }}</div>
            </div>
            <div>
              <div>
                <img class="zp" :src="photo" alt="暂无照片" />
                <!-- <JADP-UploadImg
                  class="zp"
                  v-model="photoList"
                  :fileSize="2"
                  sizeUnit="MB"
                  :limit="1"
                  disabled
                >
                </JADP-UploadImg> -->
              </div>
            </div>
          </div>
        </el-col>
      </el-row>
      <el-divider content-position="left">附件</el-divider>
      <el-row class="JADP-common-search-box" :gutter="15">
        <el-form :model="dataForm" label-position="right">
          <el-col :span="13">
            <el-form-item label="登记表附件：" prop="registration">
              <JADP-UploadFz
                v-model="registrationList"
                :fileSize="2"
                sizeUnit="MB"
                :limit="9"
                buttonText="点击上传"
                disabled
              >
              </JADP-UploadFz>
            </el-form-item>
          </el-col>

          <el-col :span="13">
            <el-form-item label="学历证明附件：" prop="academic">
              <JADP-UploadFz
                v-model="academicList"
                :fileSize="2"
                sizeUnit="MB"
                :limit="9"
                disabled
              >
              </JADP-UploadFz>
            </el-form-item>
          </el-col>

          <el-col :span="13">
            <el-form-item label="身份证附件：" prop="idcard">
              <JADP-UploadImg
                v-model="idcardList"
                :fileSize="20"
                sizeUnit="MB"
                :limit="9"
                buttonText="点击上传"
                disabled
              >
              </JADP-UploadImg>
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label="学员照片：" prop="photo">
              <JADP-UploadImg
                class="zp"
                v-model="photoList"
                :fileSize="2"
                sizeUnit="MB"
                :limit="1"
                disabled
              >
              </JADP-UploadImg>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <el-divider content-position="left">审核意见</el-divider>
      <el-col :span="24">
        <el-input
          v-model="dataForm.shenhe"
          placeholder="请输入..."
          :style="{ width: '100%' }"
          true
          type="textarea"
          :autosize="{ minRows: 4, maxRows: 4 }"
        >
        </el-input>
      </el-col>
      <div slot="footer" style="padding-right: 20px">
        <el-button type="danger" @click="submit('审核不通过')"
          >审核不通过</el-button
        >
        <el-button type="success" @click="submit('审核通过')">通过</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import request from "@/utils/request";
export default {
  name: "",
  data() {
    return {
      photo: "",
      dataForm: {
        certificatestype: "",
        certificatesnumber: undefined,
        account: undefined,
        realname: undefined,
        gender: "",
        mobilephone: undefined,
        company: undefined,
        companytype: "",
        persontype: "",
        department: undefined,
        education: "",
        title: undefined,
        registration: [],
        academic: [],
        idcard: [],
        photo: [],
        auditopinion: undefined,
        creatoruserid: "",
        creatortime: "",
        lastmodifyuserid: "",
        lastmodifytime: "",
        accountstatus: "7abdc53a877d4d9ba16fcbddf4a102d6",
        qualification: "28793a58bdbe4637ab89ad682b2fea5c",
        expirationtime: undefined,
        shenhe: "",
        shresult: "",
        chargeFlag: ""
      },
      orderId: "",
      photoList: [],
      registrationList: [],
      academicList: [],
      idcardList: [],
      photoList: [],
      priceValue: null
    };
  },
  methods: {
    async init(id, orderId, price) {
      this.orderId = orderId;
      this.priceValue = price;
      this.registrationList = [];
      this.academicList = [];
      this.idcardList = [];
      this.photoList = [];
      try {
        let { data } = await request({
          url: `/api/students/Xy_ks_students/${id}`,
          method: "get"
        });
        this.dataForm = data;

        this.registrationList = this.dataForm.registration
          ? JSON.parse(this.dataForm.registration)
          : [];
        this.academicList = this.dataForm.academic
          ? JSON.parse(this.dataForm.academic)
          : [];
        this.idcardList = this.dataForm.idcard
          ? JSON.parse(this.dataForm.idcard)
          : [];
        this.photoList = this.dataForm.photo
          ? JSON.parse(this.dataForm.photo)
          : [];
        if(this.dataForm.photo!='[]' && this.dataForm.photo!=null){
          this.photo = JSON.parse(this.dataForm.photo)[0].url;
        }else{
          this.photo ="[]";
        }
      } finally {
      }
    },
    // 报名审核提交
    submit(val) {
      if (this.priceValue == 0) {
        // 收费标识（0-免费 1-收费）
        this.dataForm.chargeFlag = "0";
      } else {
        this.dataForm.chargeFlag = "1";
      }
      this.$set(
        this.dataForm,
        "registration",
        this.registrationList.length
          ? JSON.stringify(this.registrationList)
          : ""
      );
      this.$set(
        this.dataForm,
        "academic",
        this.academicList.length ? JSON.stringify(this.academicList) : ""
      );
      this.$set(
        this.dataForm,
        "idcard",
        this.idcardList.length ? JSON.stringify(this.idcardList) : ""
      );
      this.$set(
        this.dataForm,
        "photo",
        this.photoList.length ? JSON.stringify(this.photoList) : ""
      );
      this.dataForm.shresult = val;
      this.dataForm.orderstatus =
        val == "审核不通过" ? "报名审核不通过" : "报名成功等待付款";
      console.log(this.dataForm, "this.dataForm");
      request({
        url: "/api/orders/Xy_ks_orders/" + this.orderId,
        method: "PUT",
        data: this.dataForm
      }).then(res => {
        this.$message({
          message: res.msg,
          type: "success",
          duration: 1000,
          onClose: () => {
            this.$emit("update:visible", false);
            this.$emit("refresh", true);
          }
        });
      });
    }
  }
};
</script>
<style scoped lang="scss">
::v-deep .el-dialog__body {
  padding-top: 0;
  height: 70vh;
  min-width: 50%;
  overflow-y: auto;
}
::v-deep .el-form-item {
  .el-form-item__label {
    width: 130px;
  }
  width: 100%;
  display: flex;
  .el-input,
  .el-select,
  .el-cascader,
  .comSelect-container,
  .el-date-editor {
    width: 100%;
  }
}
.student-info {
  display: flex;
  height: 205px;
  font-size: 14px;
  white-space: nowrap;

  & > div {
    display: flex;
    flex-direction: column;
    border-top: 1px solid rgb(224, 224, 224);
    border-bottom: 1px solid rgb(224, 224, 224);
    > div {
      color: #000;
      border: 1px solid rgb(224, 224, 224);
      border-right: none;
      border-top: none;
      line-height: 40px;
      text-align: center;
    }
  }
  & > div:first-child {
    flex: 1;
    border-bottom: none;
  }
  & > div:nth-child(2) {
    flex: 1.5;
    border-bottom: none;
  }
  & > div:nth-child(3) {
    flex: 1;
    border-bottom: none;
  }
  & > div:nth-child(4) {
    flex: 2;
    border-bottom: none;
  }
  & > div:last-child {
    width: 180px;
    height: 206px;
    .zp {
      width: 180px;
      height: 100%;
    }
    & > div {
      height: 100%;
      border-bottom: none;
      border-right: 1px solid rgb(224, 224, 224);
    }
  }
}
.JADP-common-search-box ::v-deep .el-form-item .el-form-item__content {
  margin-top: -6px;
}
</style>
